<%-- 
    Document   : viewVotes
    Created on : Mar 16, 2011, 4:37:09 PM
    Author     : ChuckToh
--%>
<%@page import="NicholasValueBeans.VoteTopics"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<h3>Vote topics</h3>
<%
            VoteTopics vote = new VoteTopics();
            String[] voteTopics = vote.getVoteTopics();
            int voteListId = vote.getVoteListId();
            pageContext.setAttribute("voteTopics", voteTopics);
%>

<c:choose>
    <c:when test="${empty voteTopics}">
        <h4>No topics available for voting!</h4>
    </c:when>

    <c:otherwise>
        <c:choose>
            <c:when test="${!empty afterVoteMessage}">
                <c:out value="${afterVoteMessage}" escapeXml="false"></c:out>
                <c:remove var="afterVoteMessage" scope="session"></c:remove>
                <font size="-1"><br/><br/>Please refresh the page to do voting.</font>
            </c:when>

            <c:otherwise>
                <form action="../processVote" method="post">
                    <input type="hidden" name="voteListId" value="<%=voteListId%>">
                    <table cellpadding="2" cellspacing="2">
                        <c:forEach var="voteTopic" items="${voteTopics}">
                            <tr>
                                <td><input name="topic" type="radio" value="${voteTopic}"></td>
                                <td><c:out value="${voteTopic}"></c:out></td>
                            </tr>
                        </c:forEach>

                        <tr>
                            <td align="right" colspan="2"><input type="submit" value="Vote!"></td>
                        </tr>
                    </table>
                </form>
            </c:otherwise>
        </c:choose>
    </c:otherwise>
</c:choose>